<?php
/*
 初始化框架
*/
defined('JSJZJX')||exit('非法访问！');
header("Content-type:text/html;charset=utf-8");
date_default_timezone_set("PRC");
define('DEBUG',true);
if(defined('DEBUG')){
 	error_reporting(E_ALL);
 }else{
 	error_reporting(0);
 }
 // 初始化当前的绝对路径
// 换成正斜线是因为 win/linux都支持正斜线,而linux不支持反斜线
 
//define('ROOT',str_replace('\\','/',dirname(dirname(__FILE__))) . '/');
define('ROOT',dirname(str_replace('\\','/',__DIR__)).'/');

require(ROOT . 'include/lib_base.php');

require(ROOT.'include/mysmarty.class.php');


 function __autoloadmy($class){
 	if(strtolower(substr($class,-5))=='model'){
 		require(ROOT.'/Model/'.$class.'.class.php');
 	}else if(strtolower(substr($class,-4)) == 'tool') {
        require(ROOT . 'tool/' . $class . '.class.php');
    }else{
 		require(ROOT.'include/'.$class.'.class.php');
 	}
 }

spl_autoload_register('__autoloadmy');


// 过滤参数,用递归的方式过滤$_GET,$_POST,$_COOKIE
$_GET = _addslashes($_GET);
$_POST = _addslashes($_POST);
$_COOKIE = _addslashes($_COOKIE);

session_start();

$smarty=new mysmarty();



function run(){

    if(!empty($_SERVER['PATH_INFO'])){
    	$parray=$_SERVER['PATH_INFO'];
    	$url=$_SERVER['REQUEST_URI'];
    	$str=explode("/",trim($parray,"\/"));
        //$str[0]."<br/>";
    	$c=$str[0];
        $method=$str[1];
        
        print_r($_SERVER);
    }else{
    	 $c=isset($_REQUEST['c'])?$_REQUEST['c']:"index";
	
	$method=isset($_REQUEST['a'])?$_REQUEST['a']:"index";
	
	if($c=='login'){

	}else{
		if(!isset($_SESSION['uname'])){
	    	$message = new MessageTool();
	    	$message->redirect("./index.php?c=login&a=login");
	    	exit;
	    }


    }
}
  	
	    $cname=$c.'controller';
		$cpath='admin/'.$cname.'.php';
		require(ROOT.$cpath);
		$controller=new $cname;
		$controller->$method();

	


}
?>